﻿using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework;
using Rites;

namespace Rites
{
    public class UIManager
    {
        public UIChatbox Chatbox { get; set; }

        public string PlayerName{ get; set; }

        public UIManager()
        {
        }

        public void LoadContent(ContentManager content)
        {
            Chatbox.LoadContent(content);
        }

        public void InitUI(GraphicsDeviceManager gdm, TextEventDelegate chatEvent, string plrName)
        {
            int chatWidth = (int)(gdm.PreferredBackBufferWidth * 0.50);
            int chatHeight = (int)(gdm.PreferredBackBufferHeight / 4);
            int chatLeft = 2;
            int chatTop = gdm.PreferredBackBufferHeight - chatHeight - 2;
            Chatbox = new UIChatbox(chatLeft, chatTop, chatWidth, chatHeight, Constants.KEYBOARD_BUFFERSIZE);
            Chatbox.TextCommand += new TextEventDelegate(chatEvent);
            Chatbox.PlayerName = plrName;
            PlayerName = Chatbox.PlayerName;
        }

        public void HandleInput(InputHandler inputHandler)
        {
            Chatbox.HandleInput(inputHandler);
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            Chatbox.Draw(spriteBatch);
        }
    }
}